class Person {
    private String name;//封装
    //private权限只能在当前类当中才能够使用
    private int age;

    public Person() {

    }
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Person(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    private void eat() {//封装
        System.out.println("吃饭");
    }

    public void show() {
        System.out.println(name+" "+age);
    }

    @Override//注解
    public String toString() {
        return "数据是：{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Test {
    public static void main(String[] args) {
        Person person = new Person("zhangsan",18);
        System.out.println(person);
        //person.show();
    }
    public static void main1(String[] args) {
        Person person = new Person("zhangsan",10);
        person.setName("hyj");
        System.out.println(person.getName());
        person.show();
        //person.name = "hyj";
        //person.eat();
    }
}
